package com.fysports.web.kit.commons;

import com.jfinal.log.Log;

import java.text.DecimalFormat;
import java.util.UUID;


/**
 * UUID 工具类
 * Created by konbluesky
 * Date : 14-8-3 下午4:16
 * Project : JdmData_WebServer
 */
public class UUIDKit {
    @SuppressWarnings("unused") private static Log log = Log.getLog(UUIDKit.class);


    /**
     * double精度调整
     *
     * @param doubleValue 需要调整的值123.454
     * @param format      目标样式".##"
     * @return
     */
    public static String decimalFormatToString(double doubleValue, String format) {
        DecimalFormat myFormatter = new DecimalFormat(format);
        String formatValue = myFormatter.format(doubleValue);
        return formatValue;
    }


    /**
     * 获取UUID by jdk
     *
     * @return
     */
    public static String getUuidByJdk(boolean is32bit) {
        String uuid = UUID.randomUUID().toString();
        if (is32bit) {
            return uuid.toString().replace("-", "");
        }
        return uuid;
    }


    public static void main(String[] args) {
        System.out.println(getUuidByJdk(true));
        System.out.println(getUuidByJdk(true));
        System.out.println(getUuidByJdk(true));
        System.out.println(getUuidByJdk(true));
        System.out.println(getUuidByJdk(true));
        System.out.println(getUuidByJdk(true));
        System.out.println(getUuidByJdk(true));
        System.out.println(getUuidByJdk(true));
        //        System.out.println(getUuidByJdk(false));
    }
}
